<?php
header('content-type:text/html;charset=utf-8');

include '../include/init.php';



$id=isset($_POST['id'])?trim($_POST['id']):die('ACCESS DENIT');

$pwd=isset($_POST['pwd'])?trim($_POST['pwd']):die('ACCESS DENIT');
$repwd=isset($_POST['repwd'])?trim($_POST['repwd']):die('ACCESS DENIT');

$email=isset($_POST['email'])?trim($_POST['email']):die('ACCESS DENIT');

if($pwd==''||$repwd==''||$pwd!=$repwd)
{
	die('<center><font color="red"><h2>您的输入有误，请重新操作。<a href="javascript:window.opener=null;window.open(\'\',\'_self\');window.close();">关闭本页面</a></h2></font></center>');
}
session_start();
$usr=new userModel();

$user=$usr->getbyid($id);

if($user)
{
	if($user['email']==$email)
	{
		if($usr->modify($id,'pwd',$pwd))
		{
			session_unset();
			session_destroy();
			die('<center><h2>成功修改密码！<a href="javascript:window.opener=null;window.open(\'\',\'_self\');window.close();">关闭本页面</a></h2></center>');
		}
		else
		{
			session_unset();
			session_destroy();
			die('<center><font color="red"><h2>系统繁忙，暂时未修改密码，您可以重新尝试。<a href="javascript:window.opener=null;window.open(\'\',\'_self\');window.close();">关闭本页面</a></h2></font></center>');
		}
	}
	else
	{
		session_unset();
		session_destroy();
		die('<center><font color="red"><h2>用户不存在，非法操作！</h2></font></center>');
	}
}
else
{
	session_unset();
	session_destroy();
	die('<center><font color="red"><h2>用户不存在，非法操作!</h2></font></center>');
}

